package com.demo.bigdata

import org.apache.spark.{SparkConf, SparkContext}

object JoinDemo {
  def main(args: Array[String]): Unit = {
    val conf = (new SparkConf).setMaster("local").setAppName("Demo");
    val sc = new SparkContext(conf)
    val lines0 = sc.parallelize(List(("Hadoop",2),("Spark",1),("Hive",1),("Hbase",1)))
    val lines1 = sc.parallelize(List(("Hadoop",true),("Hive",false),("Sqoop",true)))
    val join = lines0.join(lines1)
    join.foreach(println(_))
    val leftJoin = lines0.leftOuterJoin(lines1)
    leftJoin.foreach(println(_))
    val rightJoin = lines0.rightOuterJoin(lines1)
    rightJoin.foreach(println(_))
  }
}
